package com.example.mydefineview;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Button;

import com.example.mydefineview.view.MyListView;
import com.example.mydefineview.view.ZuHeView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private ZuHeView zuhe;
    private Button modyfy;
    private MyListView listview;
    private List<String>contentList=new ArrayList<String>();
    private MyAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
       /* zuhe = ((ZuHeView) findViewById(R.id.zuhe));
        modyfy = ((Button) findViewById(R.id.modyfy));
        modyfy.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                zuhe.setTitleText("修改title");
            }
        });*/
        initList();
        listview = ((MyListView) findViewById(R.id.listview));

        listview.setOnDeleteListener(new MyListView.OnDeleteListener() {
            @Override
            public void onDelete(int position) {
                contentList.remove(position);
                adapter.notifyDataSetChanged();
            }
        });
        adapter = new MyAdapter(this,0,contentList);
        listview.setAdapter(adapter);
    }

    private void initList() {
        contentList.add("Content Item 1");
        contentList.add("Content Item 2");
        contentList.add("Content Item 3");
        contentList.add("Content Item 4");
        contentList.add("Content Item 5");
        contentList.add("Content Item 6");
        contentList.add("Content Item 7");
        contentList.add("Content Item 8");
        contentList.add("Content Item 9");
        contentList.add("Content Item 10");
        contentList.add("Content Item 11");
        contentList.add("Content Item 12");
        contentList.add("Content Item 13");
        contentList.add("Content Item 14");
        contentList.add("Content Item 15");
        contentList.add("Content Item 16");
        contentList.add("Content Item 17");
        contentList.add("Content Item 18");
        contentList.add("Content Item 19");
        contentList.add("Content Item 20");
    }
}
